<?php

namespace common\tools;


use GuzzleHttp\Client as Http;
/**
 * Desc 发送请求类
 * * */
class Client{

    public static function clientRequest($url, $query, $header, $method='post'){
        $client   = new Http();
        if(empty($header)) {
            $header = [
                'Accept' => 'application/json',
	            'Accept-Charset' => 'utf-8'
            ];
        }
        try {
            if ($method == 'post') {
                $res = $client->post($url,['body' => $query,'headers'=>$header])->getBody()->getContents();
            } else {
                $res = $client->get($url,['query' => $query,'headers'=>$header])->getBody()->getContents();
            }
            return $res;
        }catch (\Exception $e){
            return false;
        }
    }


   

}